package com.scitc.pleasurevideo.util;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

import static android.Manifest.permission.ACCESS_NETWORK_STATE;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static com.tataera.stat.StatApplication.getApplicationContext;

public class AndroidUtil {
    public static boolean isWifiAccess(final Context mContext) {
		ConnectivityManager mConnectivityManager = (ConnectivityManager) mContext
				.getSystemService(Context.CONNECTIVITY_SERVICE);
		int networkType = -1;
		if (mContext.checkCallingOrSelfPermission(ACCESS_NETWORK_STATE) == PERMISSION_GRANTED) {
			NetworkInfo activeNetworkInfo = mConnectivityManager
					.getActiveNetworkInfo();
			networkType = activeNetworkInfo != null ? activeNetworkInfo
					.getType() : -1;
		}
		return ConnectivityManager.TYPE_WIFI == networkType;
	}
    public static boolean isNetworkConnected(Context context) {
		ConnectivityManager connMgr = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
		return (networkInfo != null && networkInfo.isConnected());
	}
}
